import autoprefixer from 'autoprefixer'
import postcssPresetEnv from 'postcss-preset-env'
import postcssAddRootSelector from 'postcss-add-root-selector'

export default {
  plugins: [
    tailwindcss(), // 必须在第一
    postcssPresetEnv({
      stage: 3,
      features: { 'nesting-rules': true }
    }),
    postcssAddRootSelector({ 
      rootSelector: '#root',
      transform(prefix, selector) {
        // 跳过 Tailwind 的 @layer 和基础样式
        if (selector.startsWith('@layer') || selector.includes('::')) return selector;
        return `${prefix} ${selector}`;
      }
    }),
    autoprefixer()
  ]
}
